<template>
    <el-select v-model="modelValue" clearable style="width: 200px;" ploaceholder=" 请选择供应商" @change="onChange">
        <el-option v-for="item in vendorData" :key="item.id" :label="item.name" :value="item.id" />
    </el-select>
</template>

<script setup lang="ts">
const modelValue = defineModel()
const name = defineModel('name')

const vendorData = ref < any > ([])

onMounted(() => {
    callApi()
})

const onChange = (val: any) => {
    name.value = vendorData.value.find((item: any) => item.id == val).name
    console.log(name.value)
}

const callApi = () => {
    vendorApi.select().then(res => {
        vendorData.value = res
    })
}
</script>